﻿using System;
using _2DGame_Preview_Server.Services.RoomAndBattle.RoomHall.Model;
using Assets.Script.Human.Player.Config;
using Script.UiSystem.Room;
using SimpleTools.Json;
using TMPro;
using UnityEngine;
using UnityEngine.PlayerLoop;

namespace Script.UiSystem.Hall
{
    public class RoomModel : MonoBehaviour
    {

        [SerializeField] private TextMeshProUGUI roomId;
        [SerializeField] private TextMeshProUGUI capacity;
        private RoomInfo roomInfo;

        public int RoomId => roomInfo.RoomId;

        public void InitView(RoomInfo roomInfo)
        {
            this.roomInfo = roomInfo;
            roomId.text = roomInfo.RoomId.ToString();
            capacity.text = roomInfo.nowCap + "/" + roomInfo.maxCap;
        }

        public void UpdateCap(int now)
        {
            capacity.text = now + "/" + roomInfo.maxCap;
        }
        

        public void JoinRoom()
        {
            RoomController.Instance.JoinRoom(roomInfo.port);
        }

    }
}